import { $get } from "../../utils/ajax"

// pages/index/index.js
Page({
  del(e) {
    wx.showModal({
      cancelColor: 'cancelColor',
      title: '友情提示',
      content: '确定要删除吗？',
      success: res => {
        if (res.confirm) {
          let index = e.currentTarget.dataset.i
          this.data.list.splice(index, 1)
          this.setData({
            list: this.data.list
          })
        }
      }
    })


  },
  closeMark(e) {
    this.setData({
      showMark: false
    })
  },
  /**
   * 页面的初始数据
   */
  data: {
    goodslist: ['a', 'b', 'v'],
    menus: [{
        id: 1,
        text: '京东超市',
        icon: 'https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/119120/32/8890/12506/5ed4e788E0a80beb7/face83f30a9fb903.png'
      },
      {
        id: 2,
        text: '数码电器',
        icon: 'https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/119120/32/8890/12506/5ed4e788E0a80beb7/face83f30a9fb903.png'
      },
      {
        id: 3,
        text: '京东生鲜',
        icon: 'https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/119120/32/8890/12506/5ed4e788E0a80beb7/face83f30a9fb903.png'
      },
      {
        id: 4,
        text: '京东到家',
        icon: 'https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/119120/32/8890/12506/5ed4e788E0a80beb7/face83f30a9fb903.png'
      },
      {
        id: 5,
        text: '京东超市',
        icon: 'https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/119120/32/8890/12506/5ed4e788E0a80beb7/face83f30a9fb903.png'
      },
      {
        id: 6,
        text: '京东超市',
        icon: 'https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/119120/32/8890/12506/5ed4e788E0a80beb7/face83f30a9fb903.png'
      },
      {
        id: 7,
        text: '京东超市',
        icon: 'https://m.360buyimg.com/mobilecms/s120x120_jfs/t1/119120/32/8890/12506/5ed4e788E0a80beb7/face83f30a9fb903.png'
      }
    ],
    showMark: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  async getGoodsList(){
    let{goodslist} = await $get('/goodslist')
    this.setData({
      goodslist
    })
  },
  onLoad: function (options) {
    this.getGoodsList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})